﻿<Window
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:Faust.Andrew.MTG.Player"
    xmlns:Controls="clr-namespace:WPFExtensions.Controls;assembly=WPFExtensions"
    xmlns:extbehaviour="clr-namespace:WPFExtensions.AttachedBehaviours;assembly=WPFExtensions"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" x:Name="window" x:Class="Faust.Andrew.MTG.Player.MainWindow"
    Title="MTG Player" Height="300" Width="300" Background="{DynamicResource WindowBackground}" MinWidth="600" MinHeight="500" Loaded="Window_Loaded" Closing="Window_Closing" mc:Ignorable="d" Icon="MTGManagerIcon.ico">
	<Window.Resources>		
		<DataTemplate x:Key="HandHeaderTemplate">
			<Grid>
				<Label Margin="0,0,-0.001,0" Content="Hand" d:LayoutOverrides="Width, Height" Foreground="White">
					<Label.Background>
						<SolidColorBrush/>
					</Label.Background>
					<Label.LayoutTransform>
						<TransformGroup>
							<ScaleTransform/>
							<SkewTransform/>
							<RotateTransform Angle="90"/>
							<TranslateTransform/>
						</TransformGroup>
					</Label.LayoutTransform>
				</Label>
			</Grid>
		</DataTemplate>
		<DataTemplate x:Key="WorkspaceHeaderTemplate">
			<Grid>
				<Label Margin="0,0,-0.001,0" Content="Workspace" d:LayoutOverrides="Width, Height" Foreground="White">
					<Label.LayoutTransform>
						<TransformGroup>
							<ScaleTransform/>
							<SkewTransform/>
							<RotateTransform Angle="90"/>
							<TranslateTransform/>
						</TransformGroup>
					</Label.LayoutTransform>
					<Label.Background>
						<SolidColorBrush/>
					</Label.Background>
				</Label>
			</Grid>
		</DataTemplate>
	</Window.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
			<RowDefinition Height="*"/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>
        <Menu HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" >
        	<MenuItem Header="_File">
        		<MenuItem x:Name="mnuHostGame" Header="_Host Game" Click="mnuHostGame_Click" Visibility="{Binding Presenter.Model.IsInGame, Converter={StaticResource VisibleIfNotTrue}, ElementName=window, Mode=OneWay}"/>
        		<MenuItem x:Name="mnuStartGame" Header="_Start Game" Click="mnuStartGame_Click" Visibility="{Binding Presenter.Model.IsHosting, Converter={StaticResource VisibleIfTrue}, ElementName=window, Mode=OneWay}"/>
        		<MenuItem x:Name="mnuEndGame" Header="_End Game" Click="mnuEndGame_Click" Visibility="{Binding Presenter.Model.IsHosting, Converter={StaticResource VisibleIfTrue}, ElementName=window, Mode=OneWay}"/>
        		<Separator/>
        		<MenuItem x:Name="mnuJoinGame" Header="_Join Game" Click="mnuJoinGame_Click" Visibility="{Binding Presenter.Model.IsInGame, Converter={StaticResource VisibleIfNotTrue}, ElementName=window, Mode=OneWay}"/>
        		<Separator Visibility="{Binding Presenter.Model.IsInGame, Converter={StaticResource VisibleIfNotTrue}, ElementName=window, Mode=OneWay}"/>
        		<MenuItem x:Name="mnuSaveLayout" Header="Save Window Layout" Click="mnuSaveLayout_Click"/>
        		<Separator Margin="0"/>
        		<MenuItem x:Name="mnuExit" Header="E_xit" Click="mnuExit_Click"/>
        	</MenuItem>
        	<MenuItem Header="_Edit">
        		<MenuItem Header="_Enable Sound Effects" IsCheckable="True" IsChecked="{Binding Presenter.IsSoundEnabled, ElementName=window, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
        	</MenuItem>
        	<MenuItem Header="_Actions">
        		<MenuItem x:Name="mnuMulligan" Header="_Mulligan" Click="mnuMulligan_Click"/>
        		<Separator/>
        		<MenuItem Header="Randomly Reveal Cards" Click="Menu_RandomlyReveal"/>
        		<MenuItem Header="Randomly Discard Cards" Click="Menu_RandomlyDiscard"/>
        	</MenuItem>
        	<MenuItem Header="Help">
        		<MenuItem Header="_Report Issue / Send Feedback" Click="ReportIssue_Click"/>
        	</MenuItem>
        </Menu>
        <Canvas x:Name="canvas" Margin="0" Grid.Row="1">
			<Canvas.Resources>				
					<Style TargetType="{x:Type local:DockablePanel}">
						<Setter Property="extbehaviour:DragBehaviour.IsDragEnabled"
							Value="True" />
						<Setter Property="extbehaviour:DragBehaviour.X"
							Value="{Binding (Canvas.Left), RelativeSource={RelativeSource Self}}" />
						<Setter Property="extbehaviour:DragBehaviour.Y"
							Value="{Binding (Canvas.Top), RelativeSource={RelativeSource Self}}" />							
					</Style>
			</Canvas.Resources>	
        	<Controls:ZoomControl x:Name="zoomControl" Background="{x:Null}" Width="{Binding ActualWidth, ElementName=canvas, Mode=Default}" Height="{Binding ActualHeight, ElementName=canvas, Mode=Default}" >
        		<local:PlaySurface x:Name="playSurface" Grid.Row="1" />
        	</Controls:ZoomControl>
        	<local:DockablePanel x:Name="notificationsHost" Canvas.Left="91" Canvas.Top="26.04" MaxWidth="500" MaxHeight="400" Panel.ZIndex="1"/>
        	<local:DockablePanel x:Name="previewHost" Canvas.Left="273" Canvas.Top="26.04" Panel.ZIndex="1"/>
        	<local:DockablePanel x:Name="controlsHost" Canvas.Left="273" Canvas.Top="96" Visibility="{Binding Presenter.Model.IsGameStarted, Converter={StaticResource VisibleIfTrue}, ElementName=window, Mode=OneWay}" Panel.ZIndex="1"/>
        	<local:DockablePanel x:Name="playersHost" Canvas.Left="273" Canvas.Top="167" Visibility="{Binding Presenter.Model.IsGameStarted, Converter={StaticResource VisibleIfTrue}, ElementName=window, Mode=OneWay}" Panel.ZIndex="1"/>
        	<local:DockablePanel x:Name="workspaceHost" Margin="0" Width="150" Canvas.Left="91" Canvas.Top="105" Panel.ZIndex="1" />
        	<local:DockablePanel x:Name="handHost" Margin="0" Width="150" Canvas.Left="273" Canvas.Top="256" Panel.ZIndex="1" />
        	<local:DockablePanel x:Name="planeHost" Visibility="{Binding Presenter.Model.IsUsingPlanes, Converter={StaticResource VisibleIfTrue}, ElementName=window, Mode=OneWay}" Canvas.Left="91" Canvas.Top="167"/>
        </Canvas>
        <StackPanel x:Name="spLoading" Grid.Row="2" Orientation="Horizontal" Background="#FFC7C7C7" Panel.ZIndex="300" Height="30" Visibility="Collapsed">
        	<Label Content="Loading Cards" Margin="0,0,20,0"/>
        	<ProgressBar x:Name="pbLoading" Margin="0,0,-200,0"/>
        </StackPanel>                
    </Grid>
</Window>
